25
for j=0:audioSampleSize-1 % Calculate 32 samples
recons(j+1,packet) =(sum(W((j+1) + audioSampleSize*(0:15))));
end
end
% Output 32 reconstructed PCM samples
recons=recons(:); % Change back to vector
recons=recons/max(recons); % Normalize it
%% Plot the magic
if(nargin > 1)
h=figure;
hold on;
audio=audioread(filename);
audio=audio((length(audio)-length(recons)):end);
plot(audio(1:length(recons)));
xlabel('Samples');
ylabel('Amplitude');
[~,name,ext]=fileparts(filename);
plot(recons);
title([name, ext, ' ipqmf Reconstruction']);
legend('True audio','Reconstructed');
saveas(h,[name,'_ipqmf.png']);
close(h);
if((nargin == 4)|| ((nargin==3)&& (bandFlag==0)))
offset1=489;
h=figure;
hold on;
plot(audio);
xlabel('Samples');
ylabel('Amplitude');
plot(recons(offset1:end));
title({[name, ext, ' ipqmf Reconstruction'],'Delay Fixed'});
legend('True audio','Reconstructed (Fixed for delay)');
saveas(h,[name,'_D_ipqmf.png']);
close(h);
h=figure;
hold on;
plot(audio(1:1024));
plot(recons((1:1024)+offset1));
xlabel('Samples');
ylabel('Amplitude');
legend('True audio','Reconstructed (Fixed for delay)');
if(bandFlag)
title({[name, ext, ' ipqmf Reconstruction (1024 samples)'],...
'Delay Fixed', 'Specialized Subbands'});
saveas(h,[name,'_DS1024_ipqmf.png']);
else
title({[name, ext, ' ipqmf Reconstruction (1024 samples)'],...
'Delay Fixed'});
saveas(h,[name,'_D1024_ipqmf.png']);
end